package io.renren.modules.hospital.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.hospital.entity.EmrYsInfoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import io.renren.modules.hospital.entity.EmrHzInfoEntity;
import io.renren.modules.hospital.service.EmrHzInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 *
 *
 * @author starry
 * @email 2495646304@qq.com
 * @date 2024-01-29 18:00:42
 */
@RestController
@RequestMapping("hospital/emrhzinfo")
@Api(value = "EMR患者接口", tags = "EMR患者接口")
public class EmrHzInfoController {
    @Autowired
    private EmrHzInfoService emrHzInfoService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation("列表")
    //@RequiresPermissions("hospital:emrhzinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = emrHzInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{emrHzId}")
    @ApiOperation("信息")
    //@RequiresPermissions("hospital:emrhzinfo:info")
    public R info(@PathVariable("emrHzId") Integer emrHzId){
		EmrHzInfoEntity emrHzInfo = emrHzInfoService.findHzById(emrHzId);

        return R.ok().put("emrHzInfo", emrHzInfo);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("保存")
    //@RequiresPermissions("hospital:emrhzinfo:save")
    public R save(@RequestBody EmrHzInfoEntity emrHzInfo){
		emrHzInfoService.save(emrHzInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("修改")
    //@RequiresPermissions("hospital:emrhzinfo:update")
    public R update(@RequestBody EmrHzInfoEntity emrHzInfo){
		emrHzInfoService.updateById(emrHzInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation("删除")
    //@RequiresPermissions("hospital:emrhzinfo:delete")
    public R delete(@RequestBody Integer[] emrHzIds){
		emrHzInfoService.removeByIds(Arrays.asList(emrHzIds));

        return R.ok();
    }


    @RequestMapping(value = "/info_param", method = RequestMethod.GET)
    // @RequiresPermissions("generator:bbs:info")
    @ApiOperation("查找用户(不同参数)")
    public R getInfoWithParam(@RequestParam("key") String key, @RequestParam("paramType") String paramType, @RequestParam("page") int page, @RequestParam("limit") int limit){
        List<EmrHzInfoEntity> list = emrHzInfoService.getHzListByParam(key, paramType, page, limit);
        System.out.println(list);
        PageUtils res = new PageUtils(list,list.size(), limit, page);
        return R.ok().put("page", res);
    }
}
